package fab.zjitc.net.androidhomeworktab3;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * @author 朱志文
 * @data 2019/9/29 0029
 */
public class FragmentAdapter extends FragmentStatePagerAdapter {
    private List<String> mTitle;
    private List<Fragment> mFragments;

    public FragmentAdapter(FragmentManager fm, List<String> mTitle, List<Fragment> mFragments) {
        super(fm);
        this.mTitle = mTitle;
        this.mFragments = mFragments;
    }

    @Override
    public Fragment getItem(int i) {
        return mFragments.get(i);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitle.get(position);
    }
}
